package ar.com.photo_admin.domain

import java.util.Set;

class Event extends DomainObject {

	String name
	
	String description
	
	//Para ver donde almacena las fotos
	Integer number
	
	Date eventDate
	
	Set users
	
	List albums
	
	EventPhoto coverPhoto;
	
	List photos

	static belongsTo = [User]
		
	static hasMany = [albums : EventAlbum, users : User, photos : EventPhoto]

	static constraints = {
		name(blank:false)
		description(nullable:true,blank:true)
		coverPhoto(nullable:true)
		number(unique:true,nullable:false)
	}
	
	def addPhoto(EventPhoto photo){
		photos.add(photo)
		photo.event = this
	}	
	
	def removePhoto(EventPhoto photo){
		photos.remove(photo);
		photo.event = null;
	}
	
	def removeAlbum(EventAlbum album){
		albums.remove(album);
		album.event = null;
	}
}
